package com.kzj.mls.recyclerCard.cardView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.kzj.mls.R;
import com.kzj.mls.recyclerCard.basic.CardItemView;
import com.kzj.mls.recyclerCard.card.other.ServiceCard;

/**
 * Created by xyg on 2015/10/26.
 */
public class ServiceCardView extends CardItemView<ServiceCard> {

    private Context context;
    private ImageView imageView_select;
    private TextView textView_goods_name;
    private TextView textView_goods_price;
    private TextView textView_time;

    public ServiceCardView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public ServiceCardView(Context context) {
        super(context);
        this.context = context;
    }

    public ServiceCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    @Override
    public void build(final ServiceCard card) {
        super.build(card);
        imageView_select = (ImageView) findViewById(R.id.imageView_select);
        textView_goods_name = (TextView) findViewById(R.id.textView_goods_name);
        textView_goods_price = (TextView) findViewById(R.id.textView_goods_price);
        textView_time = (TextView) findViewById(R.id.textView_time);
        if (card.getServiceListBean().isIsset()) {
            imageView_select.setImageResource(R.drawable.select);
        } else {
            imageView_select.setImageResource(R.drawable.not_select);
        }
        textView_goods_name.setText(card.getServiceListBean().getGoods_name());
        textView_goods_price.setText("价格：" + card.getServiceListBean().getPrice());
        textView_time.setText("服务时长：" + card.getServiceListBean().getService_time() + "分钟");
        this.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                card.getOnNormalButtonPressedListener().onButtonPressedListener(v, card);
            }
        });
    }
}
